Every permutation of numbers can be coded by a sequence in which equals the number of all such
that ( & ), for .
Example
The sequence is the code
of the permutation .
Task
Write a program that:
reads from the standard input the length and successive
elements of the sequence ,
examines whether it is a code of some permutation of numbers ,
if so, it finds that permutation and writes it in the standard output,
otherwise it writes in the standard output one word NIE
("no").
Input
In the first line of the standard input there is a positive integer . It is the number of elements of the sequence
.
In each of the following lines there is one nonnegative integer
not greater than . It is the successive element of the
sequence .
Output
The standard output should contain:
in each of consecutive lines - one element of the permutation
, whose code is the sequence written in the standard
input,
one word NIE, if the sequence is not a code of any
permutation.
Examples
For the input data:
7
0
0
1
0
2
0
4
the correct result is:
1
5
2
6
4
7
3
For the input data:
4
0
2
0
0
the correct result is:
NIE
Task author: Krzysztof Diks.
Kontakt
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.